#include "tool.hpp"
#include "SDL_timer.h"

namespace sdl_engine {

int Fps() {
    static int fps = 0;
    static int fpsCount = 0;
    static Uint64 count = SDL_GetPerformanceCounter();

    fpsCount++;

    Uint64 pass = SDL_GetPerformanceCounter() - count;
    double millisec = pass * 1000.0 / SDL_GetPerformanceFrequency();
    if (millisec >= 1000) {
        fps = fpsCount;
        fpsCount = 0;
        count = SDL_GetPerformanceCounter();
    }

    return fps;
}

}
